log.debug("acpi = %d", self.acpi)
log.debug("apic = %d", self.apic)
- self.register_shutdown_watch()
- self.register_reboot_feature_watch()
-
return xc.hvm_build(domid = self.vm.getDomid(),
image = self.kernel,
store_evtchn = store_evtchn,
log.info("device model pid: %d", self.pid)
def recreate(self):
- self.register_shutdown_watch()
- self.register_reboot_feature_watch()
self.pid = self.vm.gatherDom(('image/device-model-pid', int))
def destroy(self, suspend = False):
- self.unregister_shutdown_watch()
- self.unregister_reboot_feature_watch();
if self.pid:
try:
sig = signal.SIGKILL
pass
self.pid = None
- def register_shutdown_watch(self):
- """ add xen store watch on control/shutdown """
- self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown",
- self.hvm_shutdown)
- log.debug("hvm shutdown watch registered")
-
- def unregister_shutdown_watch(self):
- """Remove the watch on the control/shutdown, if any. Nothrow
- guarantee."""
-
- try:
- if self.shutdownWatch:
- self.shutdownWatch.unwatch()
- except:
- log.exception("Unwatching hvm shutdown watch failed.")
- self.shutdownWatch = None
- log.debug("hvm shutdown watch unregistered")
-
- def hvm_shutdown(self, _):
- """ watch call back on node control/shutdown,
- if node changed, this function will be called
- """
- xd = xen.xend.XendDomain.instance()
- try:
- vm = xd.domain_lookup( self.vm.getDomid() )
- except XendError:
- # domain isn't registered, no need to clean it up.
- return False
-
- reason = vm.getShutdownReason()
- log.debug("hvm_shutdown fired, shutdown reason=%s", reason)
- if reason in REVERSE_DOMAIN_SHUTDOWN_REASONS:
- vm.info['shutdown'] = 1
- vm.info['shutdown_reason'] = \
- REVERSE_DOMAIN_SHUTDOWN_REASONS[reason]
- vm.refreshShutdown(vm.info)
-
- return True # Keep watching
-
- def register_reboot_feature_watch(self):
- """ add xen store watch on control/feature-reboot """
- self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
- self.hvm_reboot_feature)
- log.debug("hvm reboot feature watch registered")
-
- def unregister_reboot_feature_watch(self):
- """Remove the watch on the control/feature-reboot, if any. Nothrow
- guarantee."""
-
- try:
- if self.rebootFeatureWatch:
- self.rebootFeatureWatch.unwatch()
- except:
- log.exception("Unwatching hvm reboot feature watch failed.")
- self.rebootFeatureWatch = None
- log.debug("hvm reboot feature watch unregistered")
-
- def hvm_reboot_feature(self, _):
- """ watch call back on node control/feature-reboot,
- if node changed, this function will be called
- """
- status = self.vm.readDom('control/feature-reboot')
- log.debug("hvm_reboot_feature fired, module status=%s", status)
- if status == '1':
- self.unregister_shutdown_watch()
-
- return True # Keep watching
-
class IA64_HVM_ImageHandler(HVMImageHandler):